package com.wjp.villagemp.service.impl.manage;

import com.wjp.villagemp.mapper.manage.ClassMapper;
import com.wjp.villagemp.model.manage.ClassEntity;
import com.wjp.villagemp.service.manage.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: Jacob
 * @Date: 2019/2/11 09:46
 * @Description:
 */
@Service
public class ClassServiceImpl implements ClassService {
    @Autowired
    private ClassMapper classMapper;

    @Override
    public List<ClassEntity> listClass(int pageSize, int start, int classNum) {
        return classMapper.listClass(pageSize, start, classNum);
    }

    @Override
    public Integer countClass(int classNum) {
        return classMapper.countClass(classNum);
    }

    @Override
    public Integer insertClass(ClassEntity classEntity) {
        return classMapper.insert(classEntity);
    }

    @Override
    public Integer updateClass(ClassEntity classEntity) {
        int key = 0;
        try {
            key = classMapper.updateByPrimaryKeySelective(classEntity);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return key;
    }

    @Override
    public Integer removeClass(Integer classNum) {
        return classMapper.deleteByPrimaryKey(classNum);
    }

    @Override
    public List<ClassEntity> listAllClass() {
        return classMapper.selectAll();
    }
}
